package com.base.system.jpa.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.util.LinkedList;
import java.util.List;

@Entity
@Table(name = "permission")
@org.hibernate.annotations.Table(appliesTo = "permission", comment = "权限表")
@Data
@Accessors(chain = true)
@JsonIgnoreProperties(value = {"role"}, ignoreUnknown = true)
public class JpaPermission extends JpaBaseEntity {
    @Id
    @Column(name = "id", columnDefinition = "bigint COMMENT '主键，自动生成'")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToMany(mappedBy = "permissions")
    private List<JpaRole> role = new LinkedList<>();

    @Column(columnDefinition = "varchar(50) not null COMMENT '权限key(xxx_xxx_xxx)'", unique = true)
    private String perkey;

    @Column(columnDefinition = "varchar(50) not null COMMENT '权限中文名称'")
    private String nameZh;

    @Column(columnDefinition = "varchar(200) COMMENT '权限中文描述'")
    private String note;

    @Column(columnDefinition = "bit(1) COMMENT '页面上是否可修改'")
    private Boolean isEdit = false;
}
